﻿// ConsoleApplication1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>

#include <io.h>
#include <vector>
#include <string>
using namespace std;

class FileOperator
{
public:
	vector<string> GetFiles(string path)
	{
		vector<string> files;
		__int64 hFile = 0;
		_finddata32i64_t fileInfo;
		string p;
		if ((hFile = _findfirst32i64(p.assign(path).append("\\*").c_str(), &fileInfo)) != -1)
		{
			do
			{
				if ((fileInfo.attrib & _A_SUBDIR))
				{}
				else
				{
					files.push_back(fileInfo.name);
				}
			} while (_findnext32i64(hFile, &fileInfo) == 0);
			_findclose(hFile);
		}
		return files;
	}
};

#ifdef _WIN64 
void getJustCurrentFile(string path, vector<string>& files)
{
	//文件句柄 
	__int64 hFile = 0;
	//文件信息 
	__finddata64_t fileinfo;
	string p;
	if ((hFile = _findfirst64(p.assign(path).append("\\*").c_str(), &fileinfo)) != -1)
	{
		do
		{
			if ((fileinfo.attrib & _A_SUBDIR))
			{
				;
			}
			else
			{
				files.push_back(fileinfo.name);
			}
		} while (_findnext64(hFile, &fileinfo) == 0);
		_findclose(hFile);
	}
}
#else
void getJustCurrentFile(string path, vector<string>& files)
{
	//文件句柄 
	long hFile = 0;
	//文件信息 
	_finddata_t fileinfo;
	string p;
	if ((hFile = _findfirst(p.assign(path).append("\\*").c_str(), &fileinfo)) != -1)
	{
		do
		{
			if ((fileinfo.attrib & _A_SUBDIR))
			{
				;
			}
			else
			{
				files.push_back(fileinfo.name);
			}
		} while (_findnext(hFile, &fileinfo) == 0);
		_findclose(hFile);
	}
}
#endif

int main()
{
	string path = "D:";
	vector<string> list;
	getJustCurrentFile(path, list);

	auto op = new FileOperator();

	auto ab = op->GetFiles(path);

	
    std::cout << "Hello World!\n";
}
